package com.wyx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wyx.entity.Student;
import com.wyx.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王云翔
 * @since 2022-03-08
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService service;

    @GetMapping("/select")
    public List<Student> selectAll(){
        return service.list();
    }
    @GetMapping("/selectByCid")
    public List<Student> selectByCid(int cid){
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
        wrapper.eq("cid",cid);
        return service.list(wrapper);
    }
    @DeleteMapping("/deleteById")
    public void deleteById(int id){
        service.removeById(id);
    }
    @PutMapping("/insert")
    public void insert(@RequestBody Student student){
        service.save(student);
    }
}

